{%extends file="user/page/layout.tpl"%}


{%block name="sub-head-static"%}
    {%$pid = $smarty.get.pid%}
    {%require name="user:static/buyterm/buyterm.less"%}
    {%require name="user:static/buyterm/buyterm.js"%}
    <script>
        P.data('pid','{%$pid%}');
        P.data('amount',{%$data.amount%});
    </script>
{%/block%}

{%block name="right-content"%}
<div class="page-buyterm">

    <div class="block assets-block">
        <div class="title">{%$pid|products:'name'%}购买</div>
        <div class="left">
            <div class="year-profit">{%$pid|products:'profit_rate'%}%</div>
            <span>年化收益率</span>
        </div>

        <div class="right">
            <div class="number-block">
                <i class="ob-icon bo-icon-cycle2"></i>
                <div class="ob-context">
                    <div class="ob-title ob-title1 now-profit">￥{%$data.plat_usable_amount|format_amount:0%}</div>
                    <div class="ob-info">当前可购买份额</div>
                </div>
            </div>
            <div class="number-block">
                <i class="ob-icon bo-icon-cycle2"></i>
                <div class="ob-context">
                    <div class="ob-title ob-title1 now-profit">{%$pid|products:'time'%}</div>
                    <div class="ob-info">锁定期</div>
                </div>
            </div>
        </div>
        <div class="clear"></div>
    </div>

    <div class="block buy-block">
        <div class="line">
            <span class="second-title">账户可用余额：</span>
            <span class="money">￥{%$data.amount|format_amount:0%}</span>
            <a href="/user/recharge" class="text-link">充值</a>
        </div>

        {%if sizeof($data.coupon.list) > 0%}
            <div class="coupon-block">
                <div class="left">
                    <span class="use_icon"></span>
                </div>
                <div class="right">
                    <div class="line">使用<span class="red">“我的红包”</span></div>
                    {%foreach $data.coupon.list as $item %}
                        <div class="line">
                            <input type="checkbox" class="use_coupon" data-amount="{%$item.amount|format_amount%}" data-type="{%$item.type%}" data-id="{%$item.id%}" id="coupon-{%$item.id%}">
                            <label for="coupon-{%$item.id%}">
                                {%if $item.type == 1%} 全场红包{%elseif $item.type == 2%}定期红包{%/if%}
                                <span class="red">￥{%$item.amount|format_amount%}</span>
                                （有效期至:{%$item.expire_time|date_format:'%Y-%m-%d'%}) {%if $item.amount==100%}需购买金额超过50000元。{%elseif $item.amount == 50%}需购买金额超过30000元。{%/if%}
                            </label>
                        </div>
                    {%/foreach%}
                    <div class="line coupon_info">小提示：无论支付金额多少，此红包仅可使用一次。</div>
                </div>
                <div class="clear"></div>
            </div>
        {%/if%}

        <div class="line">
            <div class="money-input">
                <span>￥</span>
                <input type="text" class="amount" placeholder="请输入购买金额">
            </div>
        </div>
        <div class="buy_confirm">
            <div class="line">
                实际支付金额：<span class="value">￥</span>
            </div>
            <div class="line">
                {%if $data.plat_usable_amount>=1%}
                    <button class="btn btn-large btn-main btn-buy">购买</button>
                {%else%}
                    <button class="btn btn-large btn-disable">已售完</button>
                {%/if%}
            </div>
        </div>
    </div>

    <div class="block tip-block">
        <h5>温馨提示：</h5>
        <p>1.每日13:00增加可购份额。</p>
        <p>2.定期类产品在锁定期内，无法赎回。</p>
        <p>3.您可以选择到期后自动赎回到我的帐户或者自动复投（支持本金复投和本息复投），如未选择，默认到期后本息复投。</p>
    </div>
</div>
{%/block%}